package com.xmtlxx.wms.domain;

import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xmtlxx.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 挑拣出库验证码
 *
 * @author hergreen
 * @TableName T_PICK_OUT_WAREHOUSE_CODE
 */
@EqualsAndHashCode(callSuper = true)
@TableName(value = "T_SMART_CABINET_CODE")
@Data
@NoArgsConstructor
public class SmartCabinetCode extends BaseEntity implements Serializable {

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId(type = IdType.ASSIGN_UUID)
    private String id;

    /**
     * 绑定财物id(挑拣财物ID)
     */
    private String objId;

    /**
     * 类型(0-物品出柜1-一键开柜)
     */
    private Integer type;

    /**
     * 验证码
     */
    private String code;

    /**
     * 验证次数
     */
    private Integer count;

    /**
     * 状态(0:默认,1验证成功,2验证失败)
     */
    private String status;

    /**
     * 过期时间(预留)
     */
    private LocalDateTime expirationTime;

    public SmartCabinetCode(Integer type,String objId) {
        this.objId = objId;
        this.type = type;
        this.code = RandomUtil.randomNumbers(4);
        this.expirationTime = LocalDateTimeUtil.now().plusMinutes(30);
    }
}